home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / Script Tools / Examples / Regular Expression Example < prev    next >
Text File  |  1993-07-08  |  718b  |  22 lines

  1. --
  2. --    Allow the user to select the folder to be processed.  Note that the Choose Folder command
  3. --    is provided by the Script Tools package
  4. --
  5. set folderPath to choose folder¬
  6.     with prompt "Select a folder with files to scan:"
  7.  
  8. set theExpression to compile regular expression "(.*)\\.([chr])$"
  9. set theFiles to list folder folderPath
  10. set theNewFiles to {}
  11.  
  12. --
  13. --    Look at each file in the folder and do the appropriate substitutions
  14. --
  15. repeat with i from 1 to count of theFiles
  16.     set theNewFiles to theNewFiles & (substitute regular expression theExpression ¬
  17.         of (item i of theFiles) ¬
  18.         with "\\1.\\2 - save")
  19. end repeat
  20. {original:theFiles, New:theNewFiles}
  21. --    Check the result window to see the effects of this script
  22.